package io.kiki.sba.registry.server.data_store.bootstrap;

import io.kiki.sba.registry.util.OsUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;


@ConfigurationProperties(prefix = MultiClusterDataServerConfigBean.PREFIX)
public class MultiClusterDataServerConfigBean implements MultiClusterDataServerConfig {

    public static final String PREFIX = "data.remote.server";

    private volatile int syncRemoteSlotLeaderIntervalSecs = 6;

    private volatile int syncRemoteSlotLeaderTimeoutMillis = 3000;

    private volatile int syncRemoteSlotLeaderPort = 9627;

    private volatile int syncRemoteSlotLeaderConnNum = 3;

    private volatile int remoteSyncSlotLeaderExecutorThreadSize = OsUtils.getCpuCount() * 10;

    private volatile int remoteSyncSlotLeaderExecutorQueueSize = 10000;

    private volatile int remoteSyncDataIdExecutorThreadSize = OsUtils.getCpuCount() * 3;

    private volatile int remoteSyncDataIdExecutorQueueSize = 1000;

    private volatile int remoteDataChangeExecutorThreadSize = OsUtils.getCpuCount() * 3;

    private volatile int remoteDataChangeExecutorQueueSize = 3000;

    private volatile int syncSlotLowWaterMark = 1024 * 256;
    private volatile int syncSlotHighWaterMark = 1024 * 320;

    private volatile int remoteSlotSyncRequestExecutorMinPoolSize = OsUtils.getCpuCount() * 3;

    private volatile int remoteSlotSyncRequestExecutorMaxPoolSize = OsUtils.getCpuCount() * 5;

    private volatile int remoteSlotSyncRequestExecutorQueueSize = 1000;

    private volatile int multiClusterConfigReloadMillis = 60 * 1000;

    @Override
    public int getSyncRemoteSlotLeaderIntervalSecs() {
        return syncRemoteSlotLeaderIntervalSecs;
    }


    public void setSyncRemoteSlotLeaderIntervalSecs(int syncRemoteSlotLeaderIntervalSecs) {
        this.syncRemoteSlotLeaderIntervalSecs = syncRemoteSlotLeaderIntervalSecs;
    }

    @Override
    public int getSyncRemoteSlotLeaderTimeoutMillis() {
        return syncRemoteSlotLeaderTimeoutMillis;
    }

    public void setSyncRemoteSlotLeaderTimeoutMillis(int syncRemoteSlotLeaderTimeoutMillis) {
        this.syncRemoteSlotLeaderTimeoutMillis = syncRemoteSlotLeaderTimeoutMillis;
    }

    @Override
    public int getSyncRemoteSlotLeaderPort() {
        return syncRemoteSlotLeaderPort;
    }


    public void setSyncRemoteSlotLeaderPort(int syncRemoteSlotLeaderPort) {
        this.syncRemoteSlotLeaderPort = syncRemoteSlotLeaderPort;
    }

    @Override
    public int getSyncRemoteSlotLeaderConnNum() {
        return syncRemoteSlotLeaderConnNum;
    }


    public void setSyncRemoteSlotLeaderConnNum(int syncRemoteSlotLeaderConnNum) {
        this.syncRemoteSlotLeaderConnNum = syncRemoteSlotLeaderConnNum;
    }

    @Override
    public int getRemoteSyncSlotLeaderExecutorThreadSize() {
        return remoteSyncSlotLeaderExecutorThreadSize;
    }


    public void setRemoteSyncSlotLeaderExecutorThreadSize(int remoteSyncSlotLeaderExecutorThreadSize) {
        this.remoteSyncSlotLeaderExecutorThreadSize = remoteSyncSlotLeaderExecutorThreadSize;
    }

    @Override
    public int getRemoteSyncSlotLeaderExecutorQueueSize() {
        return remoteSyncSlotLeaderExecutorQueueSize;
    }


    public void setRemoteSyncSlotLeaderExecutorQueueSize(int remoteSyncSlotLeaderExecutorQueueSize) {
        this.remoteSyncSlotLeaderExecutorQueueSize = remoteSyncSlotLeaderExecutorQueueSize;
    }


    @Override
    public int getSyncSlotLowWaterMark() {
        return syncSlotLowWaterMark;
    }


    public void setSyncSlotLowWaterMark(int syncSlotLowWaterMark) {
        this.syncSlotLowWaterMark = syncSlotLowWaterMark;
    }


    @Override
    public int getSyncSlotHighWaterMark() {
        return syncSlotHighWaterMark;
    }


    public void setSyncSlotHighWaterMark(int syncSlotHighWaterMark) {
        this.syncSlotHighWaterMark = syncSlotHighWaterMark;
    }

    @Override
    public int getRemoteSlotSyncRequestExecutorMinPoolSize() {
        return remoteSlotSyncRequestExecutorMinPoolSize;
    }


    public void setRemoteSlotSyncRequestExecutorMinPoolSize(int remoteSlotSyncRequestExecutorMinPoolSize) {
        this.remoteSlotSyncRequestExecutorMinPoolSize = remoteSlotSyncRequestExecutorMinPoolSize;
    }

    @Override
    public int getRemoteSlotSyncRequestExecutorMaxPoolSize() {
        return remoteSlotSyncRequestExecutorMaxPoolSize;
    }


    public void setRemoteSlotSyncRequestExecutorMaxPoolSize(int remoteSlotSyncRequestExecutorMaxPoolSize) {
        this.remoteSlotSyncRequestExecutorMaxPoolSize = remoteSlotSyncRequestExecutorMaxPoolSize;
    }

    @Override
    public int getRemoteSlotSyncRequestExecutorQueueSize() {
        return remoteSlotSyncRequestExecutorQueueSize;
    }


    public void setRemoteSlotSyncRequestExecutorQueueSize(int remoteSlotSyncRequestExecutorQueueSize) {
        this.remoteSlotSyncRequestExecutorQueueSize = remoteSlotSyncRequestExecutorQueueSize;
    }

    @Override
    public int getRemoteDataChangeExecutorThreadSize() {
        return remoteDataChangeExecutorThreadSize;
    }


    public void setRemoteDataChangeExecutorThreadSize(int remoteDataChangeExecutorThreadSize) {
        this.remoteDataChangeExecutorThreadSize = remoteDataChangeExecutorThreadSize;
    }

    @Override
    public int getRemoteDataChangeExecutorQueueSize() {
        return remoteDataChangeExecutorQueueSize;
    }


    public void setRemoteDataChangeExecutorQueueSize(int remoteDataChangeExecutorQueueSize) {
        this.remoteDataChangeExecutorQueueSize = remoteDataChangeExecutorQueueSize;
    }

    @Override
    public int getRemoteSyncDataIdExecutorThreadSize() {
        return remoteSyncDataIdExecutorThreadSize;
    }


    public void setRemoteSyncDataIdExecutorThreadSize(int remoteSyncDataIdExecutorThreadSize) {
        this.remoteSyncDataIdExecutorThreadSize = remoteSyncDataIdExecutorThreadSize;
    }

    @Override
    public int getRemoteSyncDataIdExecutorQueueSize() {
        return remoteSyncDataIdExecutorQueueSize;
    }


    public void setRemoteSyncDataIdExecutorQueueSize(int remoteSyncDataIdExecutorQueueSize) {
        this.remoteSyncDataIdExecutorQueueSize = remoteSyncDataIdExecutorQueueSize;
    }

    @Override
    public int getMultiClusterConfigReloadMillis() {
        return multiClusterConfigReloadMillis;
    }


    public void setMultiClusterConfigReloadMillis(int multiClusterConfigReloadMillis) {
        this.multiClusterConfigReloadMillis = multiClusterConfigReloadMillis;
    }
}
